package vip.web3.admin.common.enums;

import lombok.Getter;
import vip.web3.common.exception.RRException;

import java.math.BigDecimal;

/**
 * 后台钱包操作类型
 *
 * @title: AssetsIntoType
 * @description: TODO
 * @date 2019/12/2517:25
 * aut-horaut-hor
 */
@Getter
public enum SysWalletUpdateEnum {

    /**
     * AMOUNT_CNY
     */
    AMOUNT_CNY(1, "参投余额_人民币"),

    /**
     * AMOUNT_USDT
     */
    AMOUNT_USDT(2, "参投余额_USDT"),

    /**
     * WITHDRAW_CNY
     */
    WITHDRAW_CNY(3, "提现余额_人民币"),

    /**
     * WITHDRAW_USDT
     */
    WITHDRAW_USDT(4, "提现余额_USDT"),
    ;

    private final Integer code;
    private final String desc;

    SysWalletUpdateEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static SysWalletUpdateEnum get(Integer code) {
        for (SysWalletUpdateEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    public String getRemark(BigDecimal amount) {
        if (amount.compareTo(BigDecimal.ZERO) < 0) {
            return "- " + this.getDesc();
        }
        if (amount.compareTo(BigDecimal.ZERO) > 0) {
            return "+ " + this.getDesc();
        }
        throw new RRException("金额无效!!", -1);
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
